package bintree;
//二叉树测试模块
public class TreeTest {
    public static void main(String[] args) {
        //前序
        MyBinTree binTree = new MyBinTree();
        binTree.build();
        System.out.print("前序遍历结果为：");
        binTree.preOrder(binTree.root);
        System.out.println();
        System.out.print("中序遍历结果为：");
        binTree.inOrder(binTree.root);
        System.out.println();
        System.out.print("后序遍历结果为：");
        binTree.postOrder(binTree.root);
        System.out.println();
        System.out.println("总节点个数：" + binTree.getNodes(binTree.root));//总节点个数
        System.out.println("叶子节点个数：" + binTree.getLeafNodes(binTree.root));//叶子节点个数.
        System.out.println("第 k 层的节点个数："  + binTree.getKLevelNodes(binTree.root, 1));//第 k 层的节点个数
        System.out.println("树的高度为：" + binTree.height(binTree.root) );//树的高度
        System.out.println("树中是否包含指定值val: " + binTree.contains(binTree.root, 'C'));//树中是否包含指定值val
        System.out.println("树中是否包含指定值val: " + binTree.contains(binTree.root, 'X'));//树中是否包含指定值val
         System.out.print("层序遍历打印树：");
        binTree.levelOrder(binTree.root);// "层序遍历打印树："
        System.out.println();
        System.out.println("层序遍历算出总节点个数：" + binTree.getNodesNonRecursion(binTree.root));
    }
}
